package com.annotation.factoryBean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author: qiuli
 * @date: 2022/1/7 18:29
 * @description:
 */


public class FactoryBeanTest {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(FactoryConfig.class);
        Object colorFactoryBean = applicationContext.getBean("&colorFactoryBean");
        System.out.println(colorFactoryBean.getClass());
//        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
//        for (String name : beanDefinitionNames) {
//            System.out.println(name);
//        }
//        Object colorFactoryBean = applicationContext.getBean("colorFactoryBean");
//        System.out.println("bean的类型："+colorFactoryBean.getClass());
//
//        //如果我们就想要获取这个工厂bean，我们就可以在id的前面加上一个"&"符号
//        Object colorFactoryBean2 = applicationContext.getBean("&colorFactoryBean");
//        System.out.println("bean的类型："+colorFactoryBean2.getClass());

    }
}
